package android.itv.view;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.itv.R;
import android.itv.controller.ChannelController;
import android.itv.library.ConvertChannel;
import android.itv.library.Database;
import android.itv.model.Channel;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class Watch extends Activity
{
    private Gallery gallerychannel;
    private ListView listView;
    private Button btnWatch, btnDate;
    private TextView txtTitle,txtempty;
    private ImageButton imgLoadSchedule,btnHome;
    private ProgressBar progressBar;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.watch);
        
        Database db=new Database(this);
        db.moveDB();
        
        
        
        gallerychannel=(Gallery)findViewById(R.id.gallerychannel);
        listView=(ListView)findViewById(R.id.listschedule);
        btnWatch=(Button)findViewById(R.id.btnwatch);
        btnDate=(Button)findViewById(R.id.btndate);
        btnHome=(ImageButton)findViewById(R.id.imghome);        
        txtTitle=(TextView)findViewById(R.id.txttitle);
        imgLoadSchedule=(ImageButton)findViewById(R.id.imageLoadSchedule);
        progressBar=(ProgressBar)findViewById(R.id.progressBar1);
        txtempty=(TextView)findViewById(R.id.txtempty);
        
        
        //lay danh sach kenh duoc tra ve tu service
        ArrayList<Channel>listChannels=new ArrayList<Channel>();
        listChannels=ConvertChannel.getListChannel(WaitingLogin.listChannel);
        Log.d("DANH SACH",listChannels.size()+"");
        ChannelController channelController=new ChannelController(listView,gallerychannel,btnWatch,btnDate,imgLoadSchedule,progressBar,txtTitle,btnHome,txtempty,this);
        channelController.loadChannelsToView(listChannels);
        
    }
   
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
	Log.d("key","key");
	return super.onKeyDown(keyCode, event);
    }
    
  
    
   
}
